package com.ddtech.business.web.controller;


import com.ddtech.business.web.entity.Note;
import com.ddtech.business.web.query.NoteQuery;
import com.ddtech.business.web.service.NoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 笔记表 前端控制器
 * </p>
 *
 * @author bin_pu
 * @since 2023-02-06
 */
@Api(tags = "业务-笔记表")
@RestController
@RequestMapping("/web/note")
public class NoteController {
    @Autowired
    private NoteService noteService;
    @ApiOperation(value = "分页查询笔记表")
    @GetMapping(value = "/page-list")
    public ResponseEntity getPageList(NoteQuery noteQuery) {
        return new ResponseEntity(noteService.pageList(noteQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "分页查询笔记表-PC、移动端")
    @GetMapping(value = "/page-list-pc")
    public ResponseEntity getPageListPc(NoteQuery noteQuery) {
        return new ResponseEntity(noteService.getPageListPc(noteQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "新增笔记表，PC、移动端")
    @PostMapping(value = "/create")
    public ResponseEntity create(@RequestBody Note note) {
        noteService.create(note);
        return new ResponseEntity(true,HttpStatus.OK);
    }

    @ApiOperation(value = "培训课程新增笔记表，PC、移动端")
    @PostMapping(value = "/train-create")
    public ResponseEntity trainCreate(@RequestBody Note note) {
        noteService.trainCreate(note);
        return new ResponseEntity(true,HttpStatus.OK);
    }

    @ApiOperation(value = "删除笔记表，PC、移动端")
    @PostMapping(value = "/del/{id}")
    public ResponseEntity del(@PathVariable String id) {
        noteService.del(id);
        return new ResponseEntity(HttpStatus.OK);
    }
}
